<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">
        
    </ui:define>

    <ui:define name="left">
    </ui:define>

    <ui:define name="right">
       
    </ui:define>

    <ui:define name="content">

        <h2>Manage Order Discount Group</h2>
        <h:form id="orderDiscount">
            <p:messages showDetail="true"/>
            <p:panel id="basicInfoForm" header="Create/Update Order Discount Group">
                <!--
                <h:panelGrid columns="2" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Order Discount Group: "/>
                    <p:inputText id="orderDiscountGroup" value="{odgManagerBean.odg.orderDiscountGroup}" label="Order Discount Group"/>
                </h:panelGrid>
                -->
                <h:panelGrid columns="6" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Product: "/>
                    <h:selectOneMenu id="product" value="#{odgManagerBean.product.id}" label="Product">  
                        <f:selectItem itemLabel="-- Select One --" itemValue="-1" />  
                        <f:selectItems value="#{odgManagerBean.allProduct}" var="pd" itemLabel="#{pd.productType}" itemValue="#{pd.id}"/>
                    </h:selectOneMenu> 
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value="Quantity: "/>
                    <p:inputText id="quantity" value="#{odgManagerBean.odg.quantity}" label="Quantity"/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value="Order Discount: "/>
                    <p:inputText id="orderDiscount" value="#{odgManagerBean.odg.orderDiscount}" label="Order Discount"/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    
                </h:panelGrid>
            </p:panel>
            <p:commandButton id="button" value="Save Order Discount Group" ajax="false" action="#{odgManagerBean.createOrderDiscountGroup(1)}"
                             image="ui-icon ui-icon-disk" update="panel,display"/>
            <p:commandButton id="cancel" value="Cancel" ajax="false" action="#{odgManagerBean.createOrderDiscountGroup(0)}"/>
        </h:form>


        <h:form>
            <br/><br/>
            <br/><br/>
            <p:panel id="view" header="List of Order Discount Group">
                <p:dataTable  styleClass="allaroundborder" value="#{odgManagerBean.viewAllOrderDiscount()}" var="odg"
                              paginator="true" rows="4">
                    <!--
                    <p:column sortBy="{odg.orderDiscountGroup}" filterBy="{odg.orderDiscountGroup}">
                        <f:facet name="header">
                            <h:outputText value="Order Discount Group" />
                        </f:facet>
                        <h:outputText value="{odg.orderDiscountGroup}" />
                    </p:column>s
                    -->
                      <!--
                    <p:column sortBy="{odg.product.productType}" filterBy="{odg.product.productType}">
                        
                        <h:outputText value="{odg.product.productType}" />
                    </p:column>
                      -->
                   
                 <p:column filterBy="#{odg.product.productType}"   
                          headerText="Product Type"  style="width:80px"
                          filterOptions="#{odgManagerBean.createFilterOptions()}" 
                          filterMatchMode="exact">  
                    <h:outputText value="#{odg.product.productType}" />  
                </p:column>
                    
                    <p:column sortBy="#{odg.quantity}" filterBy="#{odg.quantity}">
                        <f:facet name="header">
                            <h:outputText value="Quantity" />
                        </f:facet>
                        <h:outputText value="#{odg.quantity}" />
                    </p:column>


                    <p:column sortBy="#{odg.orderDiscount}" filterBy="#{odg.orderDiscount}">
                        <f:facet name="header">
                            <h:outputText value="Discount" />
                        </f:facet>
                        <h:outputText value="#{odg.orderDiscount}" />
                    </p:column>

                    <p:column>
                        <p:commandButton id="update" value="Update" ajax="false" action="#{odgManagerBean.updateOrderDiscountGroup(odg.id)}"
                                         update="panel,display">
                        </p:commandButton>
                        
                     
                <!--     <p:commandButton value="Delete"  update="form" action="{odgManagerBean.beforeDelete(odg.id)}" oncomplete="confirmation.show()"/> -->
                
                    </p:column>
                      
                      
                </p:dataTable>
            </p:panel>

        </h:form>
        
        <h:form>
        <p:confirmDialog message="Are you sure?" width="200"  
                         showEffect="explode" hideEffect="explode"  
                         header="Confirm" severity="alert" widgetVar="confirmation">  
            
            <p:commandButton id="yes" value="Yes" ajax ="false" update="orderDiscount"  action="#{odgManagerBean.deleteOrderDiscountGroup()}" onstart="confirmation.hide()"/>  
            <p:commandButton id="cancel" value="Cancel" oncomplete="confirmation.hide()"  />  
            
        </p:confirmDialog> 
        </h:form>


    </ui:define>

    <ui:define name="bottom">
       
    </ui:define>

</ui:composition>
